<HTML>
<HEAD>
<TITLE ID='L_STPicker_DialogTitle'>Choose a Site Term</TITLE>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=windows-1252'>
<LINK REL='stylesheet' TYPE='text/css' HREF='/widgets/bizdesk.css' ID='mainstylesheet'>

<SCRIPT LANGUAGE='VBScript'>
Option Explicit 

Dim bMultiple
Dim m_rgSelected
Dim m_strHelpTopic         ' Help Topic URL
Dim winHelpWindow          ' Window name used to display help

Sub initSiteTermList()

  ' Get the arguments out of the Scripting.Dictionary object passed in to
  ' the dialog.

  Dim objArgs
  Dim xmlSiteTermList
  
  Dim xmllistAttributes
  Dim xmlAttribute
  Dim trAttribute
  Dim tdAttribute
  Dim btnhelp
  Dim i

  m_rgSelected = Null
  window.returnValue = Null

  Set objArgs = window.dialogArguments

  Set xmlSiteTermList = objArgs.Item("SiteTermDef")
  bMultiple = objArgs.Item("Multi")
  Call tblSiteTermList.setAttribute("multiple", bMultiple)

  ' Only display help button if there is a topic
  m_strHelpTopic = objArgs.Item("HelpTopic")
  If IsNull(m_strHelpTopic) Then
    ' Hide the help button
    Set btnhelp = L_Help_Button
    btnHelp.style.display = "none"
  End If

  If Not xmlSiteTermList Is Nothing Then
  
    Set xmllistAttributes = xmlSiteTermList.selectNodes("Attribute")

    For i = 0 to (xmllistAttributes.length - 1)
      Set xmlAttribute = xmllistAttributes.item(i)
  
      ' Create a new row
      Set trAttribute = document.createElement("TR")
      ' Add this new row to the tablelist
      tblSiteTermList.AddItem trAttribute
      Set tdAttribute = trAttribute.insertCell(-1)
      tdAttribute.innerText = xmlAttribute.getAttribute("displayName")
      Call trAttribute.setAttribute("xmlNode", xmlAttribute)
      
    Next
    
  End If 'Not xmlSiteTermList Is Nothing

  ' Make things look pretty.
  Call onWndResize()
  Call tblSiteTermList.focus()

End Sub

Sub onBtnOK()

  window.returnValue = m_rgSelected
  Call window.close()

End Sub

Sub onBtnCancel()

  Call window.close()

End Sub

Sub onWndResize()

  tblHeader.style.width = divSiteTermList.clientWidth

End Sub

Sub onSiteTermSelChange()

  Dim rgItems
  Dim i
  Dim elButton
  
  m_rgSelected = Null
  
  rgItems = tblSiteTermList.GetSelectedItems()
  
  If Not bMultiple Then
    'There should only be one
    ReDim m_rgSelected(0)
    Set m_rgSelected(0) = rgItems(0).getAttribute("xmlNode")
    
  ElseIf Not IsNull(rgItems) Then 
    'Multiple
    ReDim m_rgSelected(uBound(rgItems))
    For i = 0 to uBound(rgItems)
      Set m_rgSelected(i) = rgItems(i).getAttribute("xmlNode")
    Next
  
  End If
  Set elButton = L_OK_Button
  elButton.disabled = IsNull(m_rgSelected)

End Sub

Sub onBtnHelp()
  If Not IsNull(m_strHelpTopic) Then
		If typename(winHelpWindow) = "HTMLWindow2" Then winHelpWindow.close
		Set winHelpWindow = window.open(m_strHelpTopic, "winHelpWindow", _
 					 "height=500,width=700,status=no,toolbar=yes,menubar:no,resizable=yes")
   End If
End Sub

</SCRIPT>

</HEAD>
<BODY onload='initSiteTermList()' STYLE="margin:0px;padding:10px">

<DIV STYLE='padding-bottom:4px'>
<LABEL ID='L_STPicker_StaticText' FOR='divSiteTermList'>Choose a Site Term:</LABEL>
</DIV>

<DIV CLASS='clsQueryBldr' STYLE='padding:0px'>
  <TABLE ID='tblHeader' CELLPADDING=0 CELLSPACING=0 STYLE='width:100%;margin:0px;padding:0px'>
    <TR>
      <TD ID='L_STListHeader_Text' STYLE='border:thin outset;width:150px'>Terms</TD>
    </TR>
  </TABLE>
  <DIV ID='divSiteTermList' ALIGN='center' STYLE='height:120px;overflow-y:scroll'
    LANGUAGE='VBScript' onresize='onWndResize'>
    <TABLE ID='tblSiteTermList' onselectchange='onSiteTermSelChange'
      CELLPADDING=0 CELLSPACING=0
      STYLE='width:100%;behavior:url(/widgets/exprbldrhtc/TableList.htc)'>
    </TABLE>
  </DIV>
</DIV>

<DIV ALIGN='right' STYLE='padding-top:10px'>
  <BUTTON ID='L_OK_Button' DISABLED STYLE='width:60px' onclick='onBtnOK'>OK</BUTTON>
  <SPAN STYLE='width:2px; margin:0px; padding:0px'></SPAN>
  <BUTTON ID='L_Cancel_Button' STYLE='width:60px'onclick='onBtnCancel'>Cancel</BUTTON>
  <SPAN STYLE='width:2px; margin:0px; padding:0px'></SPAN>
  <BUTTON ID='L_Help_Button' STYLE='width:60px'onclick='onBtnHelp'>Help</BUTTON>
</DIV>

</BODY>
</HTML>
